package com.gz.moreaseManager.config;

import com.gz.moreaseManager.core.base.Constants;
import org.springframework.boot.system.ApplicationHome;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

	/**
	 * 图片绝对地址映射
	 */
	@Override
	public void addResourceHandlers(ResourceHandlerRegistry registry) {
		String appHome = new ApplicationHome().getDir().getPath();
		String uploadPath = appHome + Constants.SYS_CONFIG_UPLOAD_PATH;
		registry.addResourceHandler("/file/**").addResourceLocations("file:" + uploadPath);
	}
}